package fr.ants.controller.command;

import fr.ants.view.MainFrame;

public class ExitCommand implements Command {

	/**
	 * main frame.
	 */
	private final MainFrame frame;

	/**
	 * to stop the simulation before exit.
	 */
	private final StopCommand stop;

	/**
	 * Build
	 * 
	 * @param stop
	 *            command
	 * @param frame
	 *            main frame
	 */
	public ExitCommand(final StopCommand stop, final MainFrame frame) {
		this.frame = frame;
		this.stop = stop;
	}

	@Override
	public void execute() {
		stop.execute();
		frame.setVisible(false);
		frame.dispose();

	}

}
